<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>添加管理员 - 管理员管理</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="H-ui.admin v2.3，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>中文名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" value="" placeholder="中文名称" id="permisname"
                       name="permisname">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">资源类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <select class="permistype" bgcolor="#FFF" name="permistype" id="permistype">
                    <option value="1">一级目录</option>
                    <option value="2">二级目录</option>
                    <option value="3">三级目录</option>
                </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>相对路径：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" value="" placeholder="相对路径" id="relateurl"
                       name="relateurl">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" value="" placeholder="上级编号" id="parentid"
                       name="parentid">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">是否启用：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input name="isabled" type="radio" id="us_1" value="1" checked>
                    <label for="sex-1">正常</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="us_0" name="isabled" value="0">
                    <label for="sex-2">禁用</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"
                       onclick="$('#form-admin-add').submit()"/>
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<#include "include/_footer.html">
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(function () {

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").validate({
            onkeyup: false,
            focusCleanup: true,
            success: "valid",
            rules: {
                permisname: {
                    required: true,
                },
                parentid: {
                    required: true,
                    digits:true
                },
                relateurl: {
                    required: true,
                }
            },
            submitHandler: function (form) {

                $.ajax({
                    type: 'post',
                    contentType: "application/json",
                    url: '/resources/addResource',
                    data: JSON.stringify({
                        'permisname': $("#permisname").val(),
                        'permistype': $("#permistype").val(),
                        'relateurl': $("#relateurl").val(),
                        'parentid': $("#parentid").val(),
                        'isabled': $('input[name="isabled"]:checked').val(),
                    }),
                    success: function (data) {
                        if (data != null && data != ""){
                            layer.msg('未查询到上级编号!', {icon: 5, time: 1000});
                        }else {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.$("#searchUsers").click();
                            parent.layer.close(index);
                        }
                    }

                });


            }
        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>